﻿namespace IBTrader.Modules.DailyTickData
{
    using AxTWSLib;
    using IBTrader.Model;
    using IBTrader.Modules.Market;
    using System.Globalization;

    public class TickLog : TickBase
    {
        public TickLog(Store store) : base(store) { }
        protected override TickBase.Item CreateItem(string symbol) { return new Item(symbol); }
        public void Write(object _, _DTwsEvents_tickPriceEvent e)
        {
            if (Add(e.id))
                (items[e.id] as Item).Write(e.tickType, e.price.ToString(CultureInfo.InvariantCulture));
        }
        public void Write(object _, _DTwsEvents_tickSizeEvent e)
        {
            if (Add(e.id))
                (items[e.id] as Item).Write(e.tickType, e.size);
        }
        protected new class Item : TickBase.Item
        {
            internal Item(string symbol) : base(symbol) { }
            internal void Write(int tickType, object value)
            {
                base.Write(((TickType)tickType).ToString(), value);
            }
        }
    }
}